<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>07.扩展运算符应用场景.html</title>
</head>

<body>
    <div>北京1</div>
    <div>北京3</div>
    <div>北京2</div>
    <script>
        /**
         * 07.扩展运算符应用场景
         *   1. 剩余参数 可变参数...
         *   2. 修饰数组 []   去掉中括号
         *   3. 修饰对象 {}   去掉大括号
         */

        let arr01 = ["北京", "上海", "广州"]
        console.log(...arr01);
        console.log("北京", "上海", "广州");
        // 应用场景  数组的合并
        let aArray = ["北京", "上海", "广州"];
        let bArray = ["深圳", "南京", "杭州"];
        let cArray = ["无锡", "常州", "镇江"];

        let dArray = aArray.concat(bArray).concat(cArray)
        console.log(dArray);
        let eArray = [...aArray, ...bArray, ...cArray]
        console.log(eArray);
        console.log("===================");
        const stu01 = {
            name: '小明',
            age: 18
        }

        const stu02 = {
            name: '小红',
            address: "无锡市"
        }

        const stu03 = {
            ...stu01,
            ...stu02
        }
        console.log(stu03);
        const stu04 = {
            ...stu02,
            ...stu01
        }
        console.log(stu04);
        console.log("===================");
        //  将伪数组转为真实的数组
        /*
         伪数组:arguments
               节点
               自定义的
        */
        function func01() {
            console.log(arguments);
            console.log([...arguments]);

        }
        func01(1, 2, 3)
        // 节点伪数组
        const divNodes = document.querySelectorAll("div")
        console.log(divNodes);
        console.log([...divNodes]);
        // 自定义一个伪数组  由于没有迭代器 无法用 ... 转为真实数组
        const myArray = {
               0:"北京市",
               1:"上海市",
               2:"天津市",
               length:3
        }
        console.log(myArray);
        // console.log([...myArray]);

        
    </script>

</body>

</html>